import {reqCategoryList,reqMockbanner,reqMockfloor,} from "@/api/index"
export default {
    namespaced: true,
    actions:{
        list(store){
            if(!localStorage.getItem('data')){
                reqCategoryList().then(name=>localStorage.setItem('data',JSON.stringify(name.data)))
            }
                reqCategoryList().then(name=>{if(JSON.parse(localStorage.getItem('data')) !== name.data){
                    localStorage.setItem('data',JSON.stringify(name.data))
                    store.commit('LIST',JSON.parse(localStorage.getItem('data')))
                }
                })      
            store.commit('LIST',JSON.parse(localStorage.getItem('data')))
        },
        mocksbanner(store){
            reqMockbanner().then(name=>store.commit('MOCKBANNER',name.data))
        },
        floordata(store){
            reqMockfloor().then(name=>{store.commit('FLOORDATA',name)
        })
        },
    },
    mutations:{
        LIST(state,value){
            state.data = value.splice(0,15);//只保留前十五个数据
        },
        MOCKBANNER(state,value){
            state.bannerList = value
        },
        FLOORDATA(state,value){
            state.floordatas = value
        }
    },
    state:{
        data:[],
        bannerList:[],
        floordatas:[]
    },
    getters:{}
}